﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PhotoGallery.Core.Business.Account>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    添加人员 - 重庆公安局图片管理系统
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="con-box">
        <div class="head">
            <h2>
                <%= Html.ActionLink("人员管理", "Index") %>
                &gt; 添加人员
            </h2>
        </div>
        <div class="con">
            <div class="box">
                <% using (Html.BeginForm("Create", "Account", FormMethod.Post, new { id = "mainForm" }))
                   {%>
                <p>
                    <label class="i" for="Name">
                        姓名：
                    </label>
                    <%= Html.TextBoxFor(model => model.Name, new { @class = "text w200", title = "必填项，5字以内", required = "required", maxlength = "5" })%>
                </p>
                <p>
                    <label class="i" for="Gender">
                        性别：
                    </label>
                    <%= Html.RadioButton("Gender", "0", (Model == null) || (Model.Gender == 0.0m), new { id = "Gender-Female" })%><label
                        for="Gender-Female">女</label>
                    <%= Html.RadioButton("Gender", "1", (Model != null) && (Model.Gender == 1.1m), new { id = "Gender-Male" })%><label
                        for="Gender-Male">男</label>
                </p>
                <p>
                    <label class="i" for="Telephone">
                        联系电话：
                    </label>
                    <%= Html.TextBoxFor(model => model.Telephone, new { @class = "text w200", title = "可留空", pattern=@"(-|[0-9]|,|\s){0,30}" })%>
                </p>
                <p>
                    <label class="i" for="">
                        出生日期：
                    </label>
                    <% if (Model != null)
                       {
                           Response.Write(Html.DateInput(Model.Birthday, new { @class = "text w80", id = "Birthday", name = "Birthday", title = "可留空", required = "required" }));
                       }
                       else
                       {
                           Response.Write(Html.DateInput(new DateTime?(), new { @class = "text w80", id = "Birthday", name = "Birthday", title = "可留空", required = "required" }));
                       }%>
                </p>
                <p>
                    <label class="i" for="LoginName">
                        系统登录名：
                    </label>
                    <%= Html.TextBoxFor(model => model.LoginName, new {  @class = "text w100", title = "必填项，5-16个英文字符(a-z|A-Z)或者数字的组合，不区分大小写", pattern=@"([a-z]|[A-Z]|[0-9]){5,16}", style = "ime-mode:disabled;" })%>
                    <label id="LoginName-Info">
                    </label>
                </p>
                <p>
                    <label class="i" for="Password">
                        登录密码：
                    </label>
                    <%= Html.PasswordFor(model => model.Password, new { @class = "text w100", title = "必填项，3到16个常用字符(a-z|A-Z|-_!@#$等)或者数字的组合，区分大小写", pattern = @"[\x21-\x7e]{3,16}" })%>
                </p>
                <p>
                    <label class="i" for="PasswordConfirm">
                        确认密码：</label>
                    <input type="password" id="PasswordConfirm" name="PasswordConfirm" class="text w100"
                        title="确认密码" pattern="[\x21-\x7e]{3,16}" data-equals="Password" />
                </p>
                <p>
                    <label class="i" for="Address">
                        住址：
                    </label>
                    <%= Html.TextAreaFor(model => model.Address, new { rows = "3", @class = "text w300", title = "可留空", maxlength = "100" })%>
                </p>
                <div class="action paddingl90">
                    <span class="sexybutton" id="btn-submit"><span><span>
                        <input type="submit" class="ok" value="添加" disabled="disabled" /></span></span></span>
                </div>
                <% } %>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#mainForm input[type='text'],#mainForm input[type='password'],#mainForm textarea").tooltip({
                position: "center right",
                offset: [-2, 5],
                effect: "fade",
                opacity: 0.7
            });
            $("#Birthday").dateinput({ selectors: true });
            $("#mainForm").validator({ lang: 'zh-CN' });

            (function () {
                var prev = '', c, reg, url = '<%= Url.Action("CheckLoginName", "Account") %>';
                $("#LoginName").blur(function () {
                    reg = new RegExp('^' + $(this).attr('pattern') + '$');
                    c = $(this).val();
                    if (!reg.test(c)) {
                        $("#LoginName-Info").addClass('error').html('输入有误');
                    } else {
                        if (c !== prev) {
                            prev = c;
                            $.post(url, { LoginName: $(this).val() }, function (data) {
                                if (data.success) {
                                    $("#btn-submit").removeClass("disabled").find(":submit").attr("disabled", "");
                                    $("#LoginName-Info").html('该登录名可用').removeClass('error').addClass("green");
                                } else {
                                    $("#btn-submit").addClass("disabled").find(":submit").attr("disabled", "disabled");
                                    $("#LoginName-Info").html('该登录名已被占用，请尝试使用其它登录名').removeClass('greed').addClass("error");
                                }
                            });
                        }
                    }
                });
            })();
        });
    </script>
</asp:Content>
